package com.coocaa.internship.dao;

import com.coocaa.internship.pojo.PositionCollection;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author :hhd
 * @Description:
 * @date :2019/8/8 20:20
 */

@Mapper
@Component
public interface PositionCollectionDao {

    String TABLE_NAME = "position_collection";

    String INSERT_FIELDS = "user_id, position_id";

    String SELECT_FIELDS = "position_id";

    @Insert({"insert into", TABLE_NAME, "(", INSERT_FIELDS, ")", "values(#{userId}, #{positionId})"})
    Integer insertPositionCollection(PositionCollection positionCollection);

    @Select({"select", SELECT_FIELDS, "from", TABLE_NAME, "where user_id = #{userId} and position_id = #{positionId}"})
    Long selectPositionCollectionById(PositionCollection positionCollection);

    @Delete({"delete from", TABLE_NAME, "where user_id = #{userId} and position_id = #{positionId}"})
    Long deletePositionCollectionById(PositionCollection positionCollection);

    @Select({"select", SELECT_FIELDS, "from", TABLE_NAME, "where user_id = #{userId}"})
    List<Long> selectPositionCollectionByUserId(Long userId);

}
